package io.renren.modules.bmx.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.bmx.entity.SecondSubjectEntity;
import io.renren.modules.bmx.service.SecondSubjectService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author HuangKexiang
 * @email yesjava@126.com
 * @date 2021-02-20 00:57:32
 */
@RestController
@RequestMapping("bmx/secondsubject")
public class SecondSubjectController {
    @Autowired(required = false)
    private SecondSubjectService secondSubjectService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bmx:secondsubject:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = secondSubjectService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("bmx:secondsubject:info")
    public R info(@PathVariable("id") Integer id){
		SecondSubjectEntity secondSubject = secondSubjectService.getById(id);

        return R.ok().put("secondSubject", secondSubject);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bmx:secondsubject:save")
    public R save(@RequestBody SecondSubjectEntity secondSubject){
		secondSubjectService.save(secondSubject);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bmx:secondsubject:update")
    public R update(@RequestBody SecondSubjectEntity secondSubject){
		secondSubjectService.updateById(secondSubject);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bmx:secondsubject:delete")
    public R delete(@RequestBody Integer[] ids){
		secondSubjectService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
